#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main() {
    int n, m, a;
    cin >> n >> m >> a;
    vector<vector<string>> seat(n, vector<string>(m));
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            cin >> seat[i][j];
        }
    }

    vector<vector<string>> seat2(n, vector<string>(m));
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            seat2[i][j] = seat[i][j];
        }
    }

    auto last = seat2[n - 1];
    for (int i = n - 1; i > 0; --i) {
        seat2[i] = seat2[i - 1];
    }
    seat2[0] = last;
    for (int i = 0; i < n; ++i) {
        auto l2 = seat2[i][m - 1];
        for (int j = m - 1; j > 0; --j) {
            seat2[i][j] = seat2[i][j - 1];
        }
        seat2[i][0] = l2;
    }

    int count = 0;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            for (int k = 0; k < m; ++k) {
                if (seat[i][j][k] != seat2[i][j][k]) {
                    count++;
                }
            }
        }
    }
    cout << count << endl;
    return 0;
}
